package com.itchen.school.common.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SysException extends RuntimeException {

    private static final Logger log = LoggerFactory.getLogger(SysException.class);

    protected String error;

    protected int code;

    protected Object extraData;

    public Object getExtraData() {
        return this.extraData;
    }

    public void setExtraData(Object extraData) {
        this.extraData = extraData;
    }

    public String getError() {
        return this.error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public SysException(String bizMsg, Exception ex) {
        super(ex);
        this.error = bizMsg;
    }

    public SysException(String error) {
        this(error, new Object());
    }

    public SysException(String error, Object data) {
        super(error);
        this.code = 500;
        this.error = error;
        this.extraData = data;
    }

    public SysException(String error, String debugMsg) {
        super(error);
        log.error(debugMsg);
    }

    public SysException(String error, String debugMsg, Object data) {
        super(error);
        log.error(debugMsg);
        log.error(error);
        this.code = 500;
        this.error = error;
        this.extraData = data;
    }

    public SysException(int code, String error) {
        super(error);
        this.code = code;
        this.error = error;
    }

    public SysException(int code, String error, Object extraData) {
        super(error);
        this.code = code;
        this.error = error;
        this.extraData = extraData;
    }

    public SysException(int code, String error, Exception e, Object extraData) {
        this(error, e);
        this.code = code;
        this.extraData = extraData;
    }

}
